package jsyf.oa.dao.wreport;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import jsyf.oa.entity.wreport.WReportUnfinishMainEntity;
import jsyf.oa.entity.wreport.WReportUnfinishPersonEntity;
import jsyf.oa.idao.BaseDao;
import jsyf.oa.ientity.IBaseEntity;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @description: 未关闭事项回复
 * @author: wangmin
 * @creat: on 2018-9-17
 * @since: V1.0.0
 * @see jsyf.oa.web
 */
@Repository
public class WReportUnfinishReplyDao extends BaseDao {
    public WReportUnfinishReplyDao() {
        super.iBaseEntity = new WReportUnfinishMainEntity();
    }

    public Integer add(WReportUnfinishPersonEntity model) {
        return super.insert("T_WRT_UNFINISH_REPLY", model.getJSONObject());
    }

    public List<JSONObject> getTrackReplyList(String trackId) {
        StringBuffer sbSql = new StringBuffer();
        sbSql.append("select B.NAME USER_NAME,A.* from T_WRT_UNFINISH_REPLY A ");
        sbSql.append("LEFT JOIN T_SYS_USER B ON A.USER_ID=B.ID ");
        sbSql.append("WHERE A.TRACK_ID = '" + trackId + "'");

        return queryForJsonList(sbSql.toString());
    }

    @Override
    public IBaseEntity convertJson2Entity(JSONObject json) {
        return JSON.toJavaObject(json, WReportUnfinishMainEntity.class);
    }

}
